﻿<template>
    <section>
        <div class="app-wrap">
        <div class="gray-bg">
            <!--
            <div class="prompt-info">
                <span>
                    <svg class="icon" aria-hidden="true">
                        <use xlink:href="#icon-tongzhi"></use>
                    </svg>
                </span>
                <span>通知，左右滚动显示</span>
                <span class="close">
                    <svg class="icon" aria-hidden="true">
                        <use xlink:href="#icon-guanbi"></use>
                    </svg>
                </span>
            </div>
            -->
            <div class="pay-check-top">
                <div>总资产（元）</div>
                <!--<div class="mt-20 fs-23">暂无收益</div>-->
                <div class="mt-15" v-if="boolState==true">
                    <span>{{indexInfo.enterpriseProdVo.totalMonye}}</span>
                    <span class="eyes" @click="eyeshow">
                        <svg class="icon" aria-hidden="true" >
                            <use xlink:href="#icon-yanjing"></use>
                        </svg>
                    </span>
                </div>

                <div class="mt-15" v-if="boolState==false" >
                    <span>****</span>
                    <span class="eyes"  @click="eyeshow">
                        <svg class="icon" aria-hidden="true">
                            <use xlink:href="#icon-yanjing1"></use>
                        </svg>
                    </span>
                </div>
            </div>
            <div class="pay-check-middle">
                <router-link  class="cz"  to="/topUp">充值</router-link>
                <router-link  class="tx"  to="/takeCash">提现</router-link>
                <div>活期金额（元）</div>
                <div class="total" v-if="boolState==true">{{indexInfo.enterpriseProdVo.balance}}</div>
                <div class="total" v-if="boolState==false">****</div>
                <div class="info">
                    <span>预收益（元）</span>
                    <span class="b"  v-if="boolState==true">{{indexInfo.enterpriseProdVo.balancePreliminaryEarnings}}</span>
                    <span class="b"  v-if="boolState==false">****</span>
                    <span>预收益</span>
                    <span class="b">{{indexInfo.enterpriseProdVo.hqreoat}}</span>
                </div>
                <div class="prompt">
                    温馨提示：系统转账时间为{{indexInfo.startTime}}-{{indexInfo.endTime}}点，提现额度最高上限为{{indexInfo.withdrawlimit}}元，超过此额度需管理员审核。
                </div>
            </div>
            <div class="pay-check-investment">
                <div  v-for="(cal,k) in indexInfo.enterpriseProdVo.employeeOrderVoList">
                    <div class="w" v-if="cal.orderint!=0">
                        <router-link to="/investRegularly" class="more" href="javascript:void(0)">
                            <span class="blue">{{indexInfo.timeProNum}}笔</span>投资中
                            <svg class="icon" aria-hidden="true">
                                <use xlink:href="#icon-jiantou"></use>
                            </svg>
                        </router-link>
                        <div>定期金额（元）</div>
                        <div class="total" v-if="boolState==true">{{indexInfo.timeProTotal}}</div>
                        <div class="total" v-if="boolState==false">****</div>
                    </div>
                </div>
                <dl class="sub-list" v-for="(cal,k) in indexInfo.enterpriseProdVo.employeeOrderVoList" :key="k">
                    <dd v-if="cal.status==0">
                        <div class="title">
                            <span class="c">
                                <svg class="icon" aria-hidden="true">
                                    <use xlink:href="#icon-dingtou"></use>
                                </svg>
                            </span>
                            <span class="t">{{cal.enterpriseProdInfo.prodName}}</span>
                            <router-link :to="{name:'investment',params:{id:cal.enterpriseProdInfo.prodId}}" class="b" href="javascript:void(0);">投资</router-link>
                        </div>
                        <div class="content">
                            <div class="l">
                                <div class="orange">{{cal.enterpriseProdInfo.prodRate}}</div>
                                <div class="gray">收益率</div>
                            </div>
                            <div class="m">
                                <div class="b">{{cal.enterpriseProdInfo.prodTerm}}个月</div>
                                <div class="gray">产品期限</div>
                            </div>
                            <div class="r">
                                <div class="b">{{cal.enterpriseProdInfo.prodBuyMinmonye}}元起购</div>
                                <div>{{Number(cal.enterpriseProdInfo.prodRaiseLimit).toFixed(2)}}元募集上限</div>
                            </div>
                        </div>
                    </dd>
                </dl>
            </div>
            <dl class="link-list">
                <dd>
                    <router-link  to="/transactionDetail">
                        交易明细
                        <span class="jt">
                            <svg class="icon" aria-hidden="true">
                                <use xlink:href="#icon-jiantou"></use>
                            </svg>
                        </span>
                    </router-link>
                </dd>
                <dd v-if="infoState==false">
                    <router-link to="/perfectInfor" >
                        完善信息
                        <span class="p">未完善</span>
                        <span class="jt">
                            <svg class="icon" aria-hidden="true">
                                <use xlink:href="#icon-jiantou"></use>
                            </svg>
                        </span>
                    </router-link>
                </dd>
                <dd>
                    <router-link to="/userEdit">
                        修改密码
                        <span class="jt">
                            <svg class="icon" aria-hidden="true">
                                <use xlink:href="#icon-jiantou"></use>
                            </svg>
                        </span>
                    </router-link>
                </dd>
            </dl>
        </div>
        </div>
    </section>
</template>


<script>
    import util from '@/util/util'
    export default {
        name: "wealthMain",
        data(){
            return{
                boolState:true,
                infoState:false,

                //活期，定期，固定期限产品列表
                indexInfo:{
                    timeProTotal:'',
                    timeProNum:'',
                    enterpriseProdVo:{
                        employeeOrderVoList:[]
                    },
                    employeeOrderVoList:{}
                }
            }
        },
        created(){
            this.$store.dispatch('getIndexInfo',{}).then(resp=>{
                console.log("==getIndexInfo====");
                console.log(resp.data);
                this.indexInfo =resp.data;

                this.indexInfo.enterpriseProdVo.employeeOrderVoList = this.indexInfo.enterpriseProdVo.employeeOrderVoList.filter(item=>{
                    this.$set(item,'clazz',0);
                    this.$set(item,'first',0);
                    return item;
                });
                this.indexInfo.enterpriseProdVo.empTermOrderVoList = this.indexInfo.enterpriseProdVo.empTermOrderVoList.filter(item2=>{
                    this.$set(item2,'clazz',0);
                    this.$set(item2,'first',0);
                    return item2;
                })
            });
            this.whetherSigned();
        },
        methods:{
            whetherSigned(){
                console.log("==queryAgree====");
                util.axiosPost('/eebpc/agreePay/queryAgree')
                .then( res => {
                    console.log(res);
                    console.log('1');
                    if(res.data.exits == 1){
                        this.infoState = true;
                    }
                });
            },
            eyeshow(){
                if(this.boolState==false){
                    this.boolState=true;
                }else{
                    this.boolState=false
                }
            },
            //购买定期产品
            saleprod(prodId){
                sessionStorage.setItem('prodId',prodId);
                this.$router.push({path:'/buyProduct'});
            },

            //展开or收起定期购买详情
            getProdOrderDetails(e,prodId,empInstanceId,item){

                //如果是首次异步查，非首次不查询
                if(item.first==0){
                    this.$store.dispatch('getProdOrderDetails',{prodId:prodId,empInstanceId:empInstanceId}).then(resp=>{
                        console.log(resp.data);
                        //定期购买列表
                        this.$set(item,'prodOrderVoList',resp.data.prodOrderVoList);

                        if(undefined!=resp&&undefined!=resp.data){
                            //重置成非首次
                            item.first=1;
                        }
                    });
                }

                //控制列表的展示隐藏
                if(item.clazz==0){
                    item.clazz=1;  //展示
                    e.currentTarget.text='收起详情';
                }else{
                    item.clazz=0;   //隐藏
                    e.currentTarget.text='查看详情';
                }
            },


            //购买固定期限产品
            buyTermProd(prod_id){

            },

            //展开or收起固定期购买详情
            getTermOrderDetails(e,prodId,empInstanceId,item){
                 //如果是首次异步查，非首次不查询
                if(item.first==0){
                    this.$store.dispatch('getProdOrderDetails',{prodId:prodId,empInstanceId:empInstanceId}).then(resp=>{
                        console.log(resp.data);

                        //this.prodOrderVoList =resp.data;
                        this.$set(item,'prodOrderVoList',resp.data.prodOrderVoList);

                        if(undefined!=resp&&undefined!=resp.data){
                            //重置成非首次
                            item.first=1;
                        }
                    });
                }

                //控制列表的展示隐藏
                if(item.clazz==0){
                    item.clazz=1;  //展示
                    e.currentTarget.text='收起详情';
                }else{
                    item.clazz=0;   //隐藏
                    e.currentTarget.text='查看详情';
                }
            },

            //定期转活期
            unsubscribe(prod_order_id,prodTerm,prod_money_inc,prodId){
                let unsubscribeInfo={
                    prodOrderId:prod_order_id,
                    prodMoney:prod_money_inc,
                    prodTerm:prodTerm
                }

                sessionStorage.setItem('unsubscribeInfo',JSON.stringify(unsubscribeInfo))

                this.$router.push({path:'/pastToCurrent'});
            }
        }
    }
</script>

<style scoped>

</style>
